<?php
function PrepareVar_1($c)
{
	$c = str_replace("\"", "&quot;", $c);
	$c = str_replace("'", "&quot;", $c);
	$c = str_replace("<", "&lt;", $c);
	$c = str_replace(">", "&gt;", $c);
	$c = preg_replace("/[ ]{2,}/", " ", $c); //$c = ereg_replace("[ ]{2,}", " ", $c);
	$c = str_replace("\r\n", "\n", $c);
	$c = str_replace("\r", "\n", $c);
	$c = str_replace("\n", "<br>", $c);
	$c = str_replace("\$", "&#36;", $c);
	$c = trim($c);
	$c = stripslashes($c);
	return $c;
}
function PrepareVar_2($c)
{
	$c = str_replace('"', "&quot;", $c);
	$c = str_replace("'", "&quot;", $c);	
	$c = str_replace("<", "&lt;", $c);
	$c = str_replace(">", "&gt;", $c);
	$c = preg_replace("/[ ]{2,}/", " ", $c); //$c = ereg_replace
	$c = str_replace("\r\n", "\n", $c);
	$c = str_replace("\r", "\n", $c);
	$c = str_replace("\n", "<br>", $c);
	$c = str_replace("\$", "&#36;", $c);
	$c = trim($c);
	//$c = stripslashes($c);
	return $c;
}
function PrepareVar_3($c)
{
	$c = str_replace('"', "", $c);
	$c = str_replace("'", "", $c);	
	$c = str_replace("<", "", $c);
	$c = str_replace(">", "", $c);
	$c = preg_replace("/[ ]{2,}/", "", $c);
	$c = str_replace("\r", "", $c);
	$c = str_replace("\n", "", $c);
	$c = str_replace("\$", "", $c);
	$c = trim($c);
	$c = stripslashes($c);
	return $c;
}

/**
 * Функция для вставки значений в таблицы
 * Предназначена для админской части
 *
 * @param unknown_type $c
 * @return unknown
 */
function PrepareVar_4($c)
{
	if (ini_get("magic_quotes_gpc")=="1") return $c;
	return addslashes($c);
}
function ParseInput($c)
	{
		$c = str_replace("\"", "&quot;", $c);
		$c = str_replace("<", "&lt;", $c);
		$c = str_replace(">", "&gt;", $c);
		$c = preg_replace("/[ ]{2,}/", " ", $c);
		$c = str_replace("\r\n", "\n", $c);
		$c = str_replace("\r", "\n", $c);
		$c = str_replace("\n", "<br>", $c);
		$c = str_replace("\$", "&#36;", $c);
		$c = trim($c);
		$c = stripslashes($c);
		return $c;
	}
	
function TrimParse($c,$len)
	{
		$c = ParseInput($c);
		$c = substr($c,0,$len);
		return $c;
	}
?>